Return to doc.sitecore.com

Valid for Sitecore 5.2, 5.3
Passing Parameters from a Front-end Page to HttpRequest Pipeline

Q:

How can I pass parameters from a usual front-end page to HttpRequest pipeline? Session variables do not work there. Why?

A:

There is no Session state in this pipeline because it is run by ASP.NET before it has initialized its Session state provider. There is absolutely nothing we can do about that. It is hardwired into the ASP.NET page lifecycle. You should use Sitecore.Configuration.ClientContext class and its SetValue and GetValue methods for the purpose. For example:
 

Sitecore.Configuration ClientDataStore cds = Sitecore.Configuration.ClientContext.DataStore;
// value to set
string val = "/sitecore/content/home";        
// key to for the value
string key = "Key";
 
cds.SetValue(key, val);
// now GetString(key) should return a value which is equal to
// a value of the val variable
string retrieved = cds.GetValue(key) as string;